﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Dropthings.DataAccess;
using System.Collections.Generic;

namespace Dropthings.Business.Activities.PageActivities
{
    public partial class GetWidgetInstancesOnPageActivity : System.Workflow.ComponentModel.Activity
	{
		public GetWidgetInstancesOnPageActivity()
		{
			InitializeComponent();
		}

        public int PageId
        {
            get { return (int)GetValue(PageIdProperty); }
            set { SetValue(PageIdProperty, value); }
        }

        // Using a DependencyProperty as the backing store for PageId.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PageIdProperty =
            DependencyProperty.Register("PageId", typeof(int), typeof(GetWidgetInstancesOnPageActivity));



        public List<WidgetInstance> WidgetInstances
        {
            get { return (List<WidgetInstance>)GetValue(WidgetInstancesProperty); }
            set { SetValue(WidgetInstancesProperty, value); }
        }

        // Using a DependencyProperty as the backing store for WidgetInstances.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty WidgetInstancesProperty =
            DependencyProperty.Register("WidgetInstances", typeof(List<WidgetInstance>), typeof(GetWidgetInstancesOnPageActivity));




        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.WidgetInstances = DatabaseHelper.GetList<WidgetInstance, int>(DatabaseHelper.SubsystemEnum.WidgetInstance,
                this.PageId, LinqQueries.CompiledQuery_GetWidgetInstancesByPageId);

            return ActivityExecutionStatus.Closed;
        }

	}
}
